package model.persistence.daos;

import java.util.Collection;

import model.entities.Producto;
import model.persistence.HibernateSessionFactory;

import org.hibernate.Criteria;
import org.hibernate.Session;

public class ProductoDAO
{
	public static Producto getById(int id)
	{
		Session session = HibernateSessionFactory.getSessionFactory().openSession();
		return (Producto)session.load(Producto.class, id);
	}
	
	@SuppressWarnings("unchecked")
	public static Collection<Producto> getAll()
	{
		Session session = HibernateSessionFactory.getSessionFactory().openSession();
	     Criteria c = session.createCriteria(Producto.class);  
	     return c.list();
	}
}
